package com.ld.dao;

import com.ld.pojo.Student;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * @Author: Liudao
 * @Date: 2022-08-26-16:35
 * @Description:
 */
public interface StudentDao extends JpaRepository<Student,Integer>, JpaSpecificationExecutor<Student> {
//自定义两种静态查询方法
    //1. 条件查询带分页（与下面的方法功能类似）（方法名就是条件）
    Page<Student> findBySnameLikeAndAddrLike(String sname, String addr, Pageable pageable);
    //2. 条件查询带分页（自己写sql语句，与上面本质一样）
    @Query(value="select * from classes c,student st where st.cid=c.cid and st.sname like ?1 and addr like ?2",nativeQuery=true)
    Page<Student> search(String sname, String addr, Pageable pageable);

}
